import { reactive } from 'vue';
import { GetcitylistApi } from '/@/api/activityAdmin/index';

export interface OptionsType {
  label: string;
  value: string | number;
  key: string | number;
}

const defaultCustomerConfigb = {
  label: 'city',
  value: 'city',
  key: 'id',
};
export const getcitylist = async (config: OptionsType = defaultCustomerConfigb) => {
  const { label, value, key } = config;
  let customerList = reactive<OptionsType[]>([]);
  const res = await GetcitylistApi();
  customerList = res.data.map((item) => {
    return {
      label: item[value],
      value: item[label],
      key: item[key],
    };
  });
  return {
    customerList,
    sourceData: res.data,
  };
};